from django.db import models


# Create your models here.

# 老师
class Teacher(models.Model):
    # 姓名
    name = models.CharField(max_length=30)
    # 密码
    password = models.CharField(max_length=255)
    # 手机号
    phone = models.CharField(max_length=255,null=True)

    class Meta:
        db_table = '老师'

    def __str__(self):
        return self.name


class Student(models.Model):
    # 姓名
    stu_name = models.CharField(max_length=30)
    # 性别
    stu_sex = models.CharField(max_length=25)
    # 图标
    stu_icon = models.ImageField(upload_to='img')
    # 描述
    stu_describe = models.CharField(max_length=255)
    # 关联老师
    teacher = models.ForeignKey('Teacher', on_delete=models.CASCADE,null=True,blank=True)
    # 浏览次数
    count = models.IntegerField(default=0)

    class Meta:
        db_table = '学生'

    def __str__(self):
        return self.stu_name
